<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
<meta charset="UTF-8">
<title>会员列表</title>
<%@include file="/WEB-INF/admin/head.jsp"%>
<%@include file="/WEB-INF/admin/common.jsp"%>
</head>

<body class="">
	<div class="x-nav">
		<span class="layui-breadcrumb"> <a href="">首页</a> <a href="">演示</a> <a> <cite>导航元素</cite></a>
		</span> <a class="layui-btn layui-btn-small" style="line-height: 1.6em; margin-top: 3px; float: right" href="javascript:location.replace(location.href);"
			title="刷新"> <i class="layui-icon" style="line-height: 30px">ဂ</i></a>
	</div>
	<div class="x-body">
		<div class="layui-row">
			<form class="layui-form layui-col-md12 x-so">
				<input class="layui-input" autocomplete="off" placeholder="开始日" name="start" id="start"> <input class="layui-input" autocomplete="off"
					placeholder="截止日" name="end" id="end"> <input type="text" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
				<button class="layui-btn" lay-submit="" lay-filter="sreach">
					<i class="layui-icon">&#xe615;</i>
				</button>
			</form>
		</div>
		<xblock>
		<button class="layui-btn layui-btn-danger" onclick="delAll()">
			<i class="layui-icon"></i>批量删除
		</button>
		<button class="layui-btn" onclick="x_admin_show('添加管理员','${basePath}/admin/member/addMember.do')">
			<i class="layui-icon"></i>添加
		</button>
		</xblock>
		<table class="layui-table" lay-filter="mytable" id="mytable">
			<thead>
			</thead>
		</table>

	</div>
	<script type="text/html" id="toolbarDemo">
      <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
        <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
        <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
      </div>
    </script>
	<script type="text/html" id="opt">
		<button class="layui-btn layui-btn-sm" lay-event="edit">编辑</button>
        <button class="layui-btn layui-btn-sm" lay-event="setRole">分配角色</button>
        <button class="layui-btn layui-btn-sm" lay-event="delete">删除</button>  			
	</script>


	<script type="text/html" id="switchTpl">
      <!-- 这里的 checked 的状态只是演示 -->
      <input type="checkbox" name="sex" value="{{d.id}}" lay-skin="switch" lay-text="女|男" lay-filter="sexDemo" {{ d.id == 10003 ? 'checked' : '' }}>
    </script>

	<script>
		layui.config({
			base : "${basePath }/js/",
		}).use([ "table", "laydate", 'form' ], function() {
			var table = layui.table;
			var laydate = layui.laydate;
			var form = layui.form;
			//执行一个laydate实例
			laydate.render({
				elem : '#start' //指定元素
			});
			//执行一个laydate实例
			laydate.render({
				elem : '#end' //指定元素
			});
			//监听提交
			form.on('submit(sreach)', function(data) {
				var requestData = data.field;
				console.log(requestData);
				search(requestData);
				return false;
			});
			var search = function(data) {
				table.render({
					elem : '#mytable',
					url : '${basePath }/admin/member/memberListsData.do',
					page : true,
					limit : 10,
					where : data,
					cols : [ [ {
						type : 'checkbox'
					}, {
						field : 'id',
						title : 'ID',
						width : 80,
						sort : true
					}, {
						field : 'username',
						title : "登录名"
					}, {
						field : 'phone',
						title : "电话号码"
					}, {
						field : 'email',
						title : "邮箱"
					}, {
						field : 'name',
						title : "昵称"
					}, {
						field : 'regIp',
						title : "注册ip"
					}, {
						field : 'loginTimes',
						title : "登录次数"
					}, {
						field : 'status',
						title : "状态"
					}, {
						field : 'createTime',
						title : "创建时间"
					}, {
						field : 'id',
						title : "操作",
						toolbar : '#opt'
					}, ] ],
					parseData : function(res) { //res 即为原始返回的数据
						return {
							"code" : res.code, //解析接口状态
							"msg" : res.msg, //解析提示文本
							"count" : res.count, //解析数据长度
							"data" : res.lists
						//解析数据列表
						};
					},
					done : function(res, curr, count) {
						console.log(res);
					}
				});
			}

			search();
			//头工具栏事件
			table.on('tool(mytable)', function(obj) {
				var event = obj.event;
				var data = obj.data;
				if ("edit" == event) {
					x_admin_show('编辑管理员', '${basePath}/admin/member/edit/' + data.id + '.do');
				}
			});

		});
	</script>

</body>

</html>